package com.wwc.business.controller;

import com.wwc.business.controller.dto.train_seat.TrainSeatDeleteDTO;
import com.wwc.business.controller.dto.train_seat.TrainSeatInsertDTO;
import com.wwc.business.controller.dto.train_seat.TrainSeatSelectListDTO;
import com.wwc.business.controller.dto.train_seat.TrainSeatUpdateDTO;
import com.wwc.business.controller.vo.TrainSeatSelectListVO;
import com.wwc.business.service.ITrainSeatService;
import com.wwc.common.response.CommonResponse;
import com.wwc.common.response.PageResponse;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

/**
 * 座位 Controller
 */
@RestController
@RequestMapping("/admin/train-seat")
public class TrainSeatController{
	@Resource
	private ITrainSeatService trainSeatService;

	/**
	 * 新增火车座位
	 */
	@PostMapping("/insert")
	public CommonResponse<?> insert(@Valid @RequestBody TrainSeatInsertDTO trainSeatInsertDTO){
		trainSeatService.insert(trainSeatInsertDTO);
		return new CommonResponse<>();
	}

	/**
	 * 更新火车座位
	 */
	@PostMapping("/update")
	public CommonResponse<?> update(@Valid @RequestBody TrainSeatUpdateDTO trainSeatUpdateDTO){
		trainSeatService.update(trainSeatUpdateDTO);
		return new CommonResponse<>();
	}

	/**
	 * 删除火车座位
	 */
	@PostMapping("/delete")
	public CommonResponse<?> delete(@Valid @RequestBody TrainSeatDeleteDTO trainSeatDeleteDTO){
		trainSeatService.delete(trainSeatDeleteDTO);
		return new CommonResponse<>();
	}

	/**
	 * 查询火车座位分页列表
	 */
	@GetMapping("/select-list-page")
	public CommonResponse<PageResponse<TrainSeatSelectListVO>> selectListPage(@Valid TrainSeatSelectListDTO trainSeatSelectListDTO){
		PageResponse<TrainSeatSelectListVO> pageResponse = trainSeatService.selectListPage(trainSeatSelectListDTO);
		return new CommonResponse<>(pageResponse);
	}

	/**
	 * 根据车次编号生成座位
	 */
	@PostMapping("/generator-seat/{trainCode}")
	public CommonResponse<?> generatorSeat(@PathVariable String trainCode){
		trainSeatService.generatorSeat(trainCode);
		return new CommonResponse<>();
	}
}